<?php if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

class Senior_discount_model extends CI_Model {
	public function __construct() {
		parent::__construct();
	}

public function get_status($year, $month){
    		$this->db->query("DROP TABLE IF EXISTS seniorita");
    		$this->db->query("CREATE TEMPORARY TABLE seniorita AS (SELECT aa.`acct_name`, aa.`acct_num`,uil.`line_amt`, umr.`bill_month`, umr.`bill_year`, uil.`charge_code` FROM ubs_invoice_lines uil
                  JOIN ubs_invoices ui ON uil.`invoice_id` = ui.`invoice_id`
              JOIN ubs_meter_readings umr ON umr.`bill_id` = ui.`invoice_num`
              JOIN ar_account aa ON aa.`account_id` = ui.`customer_id` WHERE uil.charge_code = 'SCDISCNT')");
        //charge_code = 'SCDISCNT' AND 
        $sql = "SELECT * FROM seniorita WHERE bill_year = '".$year."' AND bill_month = '".$month."'";

        $q = $this->db->query($sql);
        return $q->result();
}


}